<?
require_once "../php/Context.php";
require_once "../php/AdminInit.php";
if(!$admin->isAuthorize())
    echo "<script>document.location.href='/Admin.php';</script>";



?>
<!DOCTYPE html>
<html lang="en" ng-app="MainModule">
<head>
    <title>Contacts</title>
    <meta charset="utf-8">
    <link rel="stylesheet" href="/css/bootstrap.min.css" type="text/css" media="all">
    <script type="text/javascript" src="../js/jquery-1.6.js"></script>
</head>
<body>
<a href="../Admin.php?logout=true">logout</a>
   <div class="container">
       <div class="row">

           <div class="col-md-6" ng-controller="ProductCtrl">
               <h1>Your products:</h1>
               <a href="/AddItem.html">Add Product</a>
               <form action="../php/SaveChanges.php" method="post">
                   <table class="table table-striped">
                       <thead>
                       <tr>
                           <th>#</th>
                           <th>Product Name</th>
                           <th>Image url</th>
                           <th>Description</th>
                           <th></th>
                           <th></th>
                       </tr>
                       </thead>
                       <tbody>
                       <tr ng-repeat="prod in prods track by $index">
                           <th scope="row"><input type="text" value="{{prod.Id}}" name="Id[]"  disabled/> </th>
                           <td><input type="text"  ng-disabled="enable!=$index" ng-model="prod.Title" name="Title[]"  /></td>
                           <td><input type="text"  ng-disabled="enable!=$index" ng-model="prod.Image" name="Image[]" /></td>
                           <td><input type="text"  ng-disabled="enable!=$index" ng-model="prod.Description_one" /></td>
                           <td><input type="text"  ng-disabled="enable!=$index" ng-model="prod.Description_two" /></td>
                           <td><input type="text"  ng-disabled="enable!=$index" ng-model="prod.Description_free" /></td>
                           <td><a href="../php/DeleteProduct.php?id={{prod.Id}}">Delete</a></td>
                           <td><a ng-hide="enable == $index"  ng-click="edit($index)" style="cursor: pointer">Edite</a>
                               <a ng-show="enable == $index" ng-click="save($index, prod)" style="cursor: pointer">Save</a>
                           </td>

                       </tr>

                       </tbody>
                   </table>
                   <input type="submit" value="Save changes"/>
               </form>

               <h1>Your messages:</h1>
                   <table class="table table-striped">
                       <thead>
                       <tr>
                           <th>#</th>
                           <th>ContactName</th>
                           <th>Email</th>
                           <th>Description</th>
                       </tr>
                       </thead>
                       <tbody>
                       <tr ng-repeat="message in Messages track by $index">
                          <td>{{message.Id}}</td>
                           <td>{{message.ContactName}}</td>
                           <td>{{message.Email}}</td>
                           <td>{{message.Description}}</td>
                       </tr>

                       </tbody>
                   </table>
               </form>
           </div>
       </div>
   </div>

   <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/angularjs/1.3.14/angular.min.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.3.14/angular-route.js"></script>
   <script type="text/javascript" src="../js/AngularControllers/ProductCtrl.js"></script>
   <script type="text/javascript" src="../js/angularModules/mainModule.js"></script>

</body>
</html>